﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;
using System.Threading.Tasks;
using System.IO;
using Windows.Storage;
using WeiboSdk;
using System.Text;

namespace WeiboSdkSample.PageViews
{
    public partial class ShareToWeiboPage : PhoneApplicationPage
    {
        public ShareToWeiboPage()
        {
            InitializeComponent();
        }

        private void btnShareText_Clicked(object sender, RoutedEventArgs e)
        {
            WeiboAssociation.ShareText(tbStatus.Text);
        }

        private void btnShareImage_Clicked(object sender, RoutedEventArgs e)
        {
            //分享图片
            PickImage();
        }

        #region Pick Image from Phone Album
        private void PickImage()
        {
            PhotoChooserTask task = new PhotoChooserTask();
            task.Show();
            task.Completed += task_Completed;
        }

        void task_Completed(object sender, PhotoResult e)
        {
            (sender as PhotoChooserTask).Completed -= task_Completed;
            if (e.ChosenPhoto != null)
            {
                WeiboAssociation.Share(e.ChosenPhoto, tbStatus.Text);
            }
        }
        #endregion

        private void btnShareLocation_Clicked(object sender, RoutedEventArgs e)
        {
            WeiboAssociation.Share(null, "#我在这里#", "10.32423", "123.4356345");
        }


    }
}